package com.guacun.service;


import com.guacun.dao.TeacherDao;
import com.guacun.model.Teacher;

import java.util.Scanner;

public class TeacherService {
    private static Scanner scanner = new Scanner(System.in);
    private TeacherDao teacherDao = new TeacherDao();

    //添加
    public int addTeacher(Teacher teacher) {
        Teacher[] list = {teacher};
        int flag = teacherDao.add(list);
        return flag;
    }
//删除
    public int deleteTeacher(int id) {
        return teacherDao.deleteteacher(id);
    }

    public int updateTeacher(int id) {
        System.out.println("请输入要修改的老师姓名:");
        String nname = scanner.next();
        System.out.println("请输入老师年龄:");
        int age = scanner.nextInt();
        System.out.println("请输入老师生日:");
        String nbrithday = scanner.next();
        return  teacherDao.updateteacherdao(new Teacher(id,nname,age,nbrithday));
    }

    public int selectTeacher() {

        int i = teacherDao.selectall();
        return i;
    }
    public Teacher selectTeacherbyid(int id) {
        Teacher selectallbyid = teacherDao.selectallbyid(id);
        System.out.println("2"+selectallbyid);
        return selectallbyid;
    }
}
